import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vite.dev/config/
export default defineConfig({
  server: {
    open: true,
    port: 8080,
    host: '0.0.0.0',
    proxy: {
      '/yuque': {
        target: 'https://cdn.nlark.com/yuque',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/yuque/, ''),
        headers: {
          Referer: 'https://www.yuque.com',
          Origin: 'https://www.yuque.com',
        },
      },
    },
  },
  plugins: [vue(), vueJsx()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
})
